import { deleteByPrimaryKeyForProOrg, selectByPrimaryKeyForProOrg, insertForProOrg, updateForProOrg, deleteByMapForProOrg,updateByMapForProOrg, getOneForProOrg,getAllForProOrg,queryPageForProOrg, countForProOrg, insertBatchForProOrg, deleteBatchForProOrg,updateBatchForProOrg } from '@/services/system/api_proorg';

export default {
    namespace: 'proorg',

    state: {
        data: {
            list: [],
            pagination: {},
        },
    },

    effects: {
            *delete_by_primarykey_for_proorg({ payload }, { call, put }) {
                const response = yield call(deleteByPrimaryKeyForProOrg, payload);
                yield put({
                    type: 'deleteByPrimaryKeyForProOrg',
                    payload: response,
                });

                const responsedata = yield call(queryPageForProOrg, {});
                yield put({
                type: 'queryPageForProOrg',
                payload: responsedata,
                });


            },
            *select_by_primarykey_for_proorg({ payload, callback }, { call, put }) {
                const response = yield call(selectByPrimaryKeyForProOrg, payload);
                yield put({
                    type: 'selectByPrimaryKeyForProOrg',
                    payload: response,
                });

                if (callback) callback();
            },
            *insert_for_proorg({ payload, callback }, { call, put }) {
                const response = yield call(insertForProOrg, payload);
                yield put({
                    type: 'insertForProOrg',
                    payload: response,
                });

                const responsedata = yield call(queryPageForProOrg, {});
                yield put({
                type: 'queryPageForProOrg',
                payload: responsedata,
                });

                if (callback) callback();
            },
            *update_for_proorg({ payload, callback }, { call, put }) {
                const response = yield call(updateForProOrg, payload);
                yield put({
                    type: 'updateForProOrg',
                    payload: response,
                });


                const responsedata = yield call(queryPageForProOrg, {});
                yield put({
                type: 'queryPageForProOrg',
                payload: responsedata,
                });

                if (callback) callback();
            },
            *delete_by_map_for_proorg({ payload, callback }, { call, put }) {
                const response = yield call(deleteByMapForProOrg, payload);
                yield put({
                    type: 'deleteByMapForProOrg',
                    payload: response,
                });


                const responsedata = yield call(queryPageForProOrg, {});
                yield put({
                type: 'queryPageForProOrg',
                payload: responsedata,
                });

                if (callback) callback();
            },
            *update_by_map_for_proorg({ payload, callback }, { call, put }) {
                const response = yield call(updateByMapForProOrg, payload);
                yield put({
                    type: 'updateByMapForProOrg',
                    payload: response,
                });


                const responsedata = yield call(queryPageForProOrg, {});
                yield put({
                type: 'queryPageForProOrg',
                payload: responsedata,
                });

                if (callback) callback();
            },
            *get_one_for_proorg({ payload, callback }, { call, put }) {
                const response = yield call(getOneForProOrg, payload);
                yield put({
                    type: 'getOneForProOrg',
                    payload: response,
                });

                if (callback) callback();
            },
            *get_all_for_proorg({ payload, callback }, { call, put }) {
                const response = yield call(getAllForProOrg, payload);
                yield put({
                    type: 'getAllForProOrg',
                    payload: response,
                });

                if (callback) callback();
            },
            *query_page_for_proorg({ payload, callback }, { call, put }) {
                const response = yield call(queryPageForProOrg, payload);
                yield put({
                    type: 'queryPageForProOrg',
                    payload: response,
                });


                if (callback) callback();
            },
            *count_for_proorg({ payload, callback }, { call, put }) {
                const response = yield call(countForProOrg, payload);
                yield put({
                    type: 'countForProOrg',
                    payload: response,
                });


                if (callback) callback();
            },
            *insert_batch_for_proorg({ payload, callback }, { call, put }) {
                const response = yield call(insertBatchForProOrg, payload);
                yield put({
                    type: 'insertBatchForProOrg',
                    payload: response,
                });


                const responsedata = yield call(queryPageForProOrg, {});
                yield put({
                type: 'queryPageForProOrg',
                payload: responsedata,
                });


                if (callback) callback();
            },
            *delete_batch_for_proorg({ payload, callback }, { call, put }) {
                const response = yield call(deleteBatchForProOrg, payload);
                yield put({
                    type: 'deleteBatchForProOrg',
                    payload: response,
                });

                const responsedata = yield call(queryPageForProOrg, {});
                yield put({
                type: 'queryPageForProOrg',
                payload: responsedata,
                });

                if (callback) callback();
            },
            *update_batch_for_proorg({ payload, callback }, { call, put }) {
                const response = yield call(updateBatchForProOrg, payload);
                yield put({
                    type: 'updateBatchForProOrg',
                    payload: response,
                });

                const responsedata = yield call(queryPageForProOrg, {});
                yield put({
                type: 'queryPageForProOrg',
                payload: responsedata,
                });

                if (callback) callback();
            },
            },

    reducers: {
        deleteByPrimaryKeyForProOrg(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        selectByPrimaryKeyForProOrg(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        insertForProOrg(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        updateForProOrg(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        deleteByMapForProOrg(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        updateByMapForProOrg(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        getOneForProOrg(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        getAllForProOrg(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        queryPageForProOrg(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        countForProOrg(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        insertBatchForProOrg(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        deleteBatchForProOrg(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        updateBatchForProOrg(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
    },
};
